<template>
	<view class="favorite">
		<button class="bor fs" @click="share" open-type="share">
			<view class="iconfont icon-share_light"></view>
			<share ref="share" :contentHeight="580" :shareList="shareList"></share>
		</button>
	</view>
</template>

<script>
	import share from '@/components/share';
	import {mapState} from 'vuex';  
	export default {
		components: {
			share
		},
		props:{
			'contentId':{
				type: String, 
				default: '0'
			},
			'ups':{
				type: Number,
				default: 0,
			}
		},
		data() {
			return {
				shareList: [],
				isKeep:false,
				isFabulous:false,
				up: 0,
			};
		},
		computed: {
			fabulous:function(){
				return this.ups + this.up;
			},
			...mapState(['hasLogin','userInfo'])
		},
		created(){
			setTimeout(()=>{
				this.loadData();
			}, 500);
		},
		methods:{
			share(){
				// #ifdef MP-WEIXIN
				wx.showShareMenu();
				// #endif
				// #ifdef H5
				this.$refs.share.toggleMask();	
				// #endif
			},
			async loadData() {
				let shareList = await this.$api.json('shareList');
				this.shareList = shareList;
				let isFabulous = uni.getStorageSync('fabulous'+this.contentId);
				if(isFabulous){
					this.isFabulous = true;
				}
				if(this.hasLogin){
					this.$api.memberGetWithoutLogin('/content/collectExit',{cId: this.contentId}).then(r=>{
						if(r.data.body == 'true'){
							this.isKeep = true;
						}else{
							this.isKeep = false;
						}
					});
				}
			},
		}
	}
</script>

<style>
.favorite {
	display: flex;
	align-items: center;
	justify-content: space-between;
	box-sizing: border-box; position: absolute;left:30upx;top:10upx
}
.favorite .bor{padding:10upx 0 ;text-align: center;}
.favorite .bor .iconfont{font-size:40upx;}
.favorite .bor .on{border:#b92121 solid 1px;color: #fff ;background: #b92121;}
uni-button:after{ display: none;}
button:after{ display: none;}
.fs{ line-height:50upx; background:none; margin: 0;font-size:28upx;}
</style>
